#include <SFML/Graphics.hpp>
#include <SFML/Graphics/View.hpp>
#include <SFML/System/Vector2.hpp>

int main()
{
	sf::View view;
	sf::Image background;
	sf::Texture texture;
	sf::Texture oanda;
	sf::Sprite sprite;
	sf::Texture * pandaText=new sf::Texture;
	sf::Sprite pandaSprite;
	float x=0;
	float y=0;
	bool exit=false;
	sf::Text text;

// select the font // font is a sf::Font

// set the string to display
text.setString("Hello world");

// set the character size
text.setCharacterSize(24); // in pixels, not points!

// set the color
text.setColor(sf::Color::Red);

// set the text style
text.setStyle(sf::Text::Bold | sf::Text::Underlined);


// inside the main loop, between window.clear() and window.display()

	pandaText->loadFromFile("Panda2.png");
	pandaText->setSmooth(true);
	pandaSprite.setTexture(*pandaText,true);
	pandaSprite.setTextureRect(sf::IntRect(0, 0, 100,100));

	texture.loadFromFile("world2.png");
	texture.setSmooth(true);
	sprite.setTexture(texture);
	sprite.setPosition(0.f, 0.f);
	sprite.setTextureRect(sf::IntRect(0, 0, 1200, 800));
    sf::RenderWindow window(sf::VideoMode(1200, 800), "SFML works!",sf::Style::Fullscreen);

    while (window.isOpen() && exit==false)
    {
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
	{
		x=x-.75;
	}
	else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
	{
		x=x+.75;
	}
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
		y=y-.75;
	}
	else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
		y=y+.75;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
	{
		exit=true;
	}
	pandaSprite.setPosition(view.getCenter());
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
		window.clear();
		window.draw(sprite);
		window.draw(pandaSprite);
		view.setSize(800,600);
		view.setCenter(x,y);
		window.setView(view);
		window.draw(text);
        window.display();
    }

    return 0;
}